package com.imut.hcdp.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.imut.hcdp.domain.HcdpTrainAll;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.imut.hcdp.common.Rst;

import com.imut.hcdp.domain.HcdpTrain;
import com.imut.hcdp.service.IHcdpTrainService;



@RestController
@RequestMapping("/system/train")
public class HcdpTrainController
{
    @Autowired
    private IHcdpTrainService hcdpTrainService;



    @GetMapping("/list")
    public Rst list(HcdpTrain hcdpTrain, HttpServletRequest request)
    {
//        String pageNum = request.getParameter("pageNum");
//        String pageSize = request.getParameter("pageSize");
//        PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
        List<HcdpTrain> list = hcdpTrainService.selectHcdpTrainList(hcdpTrain);
//        PageInfo<HcdpTrain> pageInfo = (PageInfo<HcdpTrain>)list;
        return Rst.success(list);
    }





    @GetMapping(value = "/{id}")
    public Rst getInfo(@PathVariable("id") Long id)
    {
        return Rst.success(hcdpTrainService.selectHcdpTrainById(id));
    }




    @PostMapping
    public Rst add(@RequestBody HcdpTrain hcdpTrain)
    {
        return Rst.success(hcdpTrainService.insertHcdpTrain(hcdpTrain));
    }




    @PutMapping
    public Rst edit(@RequestBody HcdpTrain hcdpTrain)
    {
        return Rst.success(hcdpTrainService.updateHcdpTrain(hcdpTrain));
    }




	@DeleteMapping("/{ids}")
    public Rst remove(@PathVariable Long[] ids)
    {
        return Rst.success(hcdpTrainService.deleteHcdpTrainByIds(ids));
    }
}
